<!-- 盘存 -->
<template>
	<view>
		<div>
			<navitop>
				<i class="iconfont icon-jiantou-copy" slot="left-slot" @click="outlot"></i>
				<span slot="center-slot">
					<h4>{{titles}}</h4>
				</span>
				<i  slot="right-slot">
					<!-- <i class="iconfont icon-sousuo1" style="font-size: 25px;padding-left: 15px;" ></i> -->
					<i class="iconfont icon-youcecaidan" style="font-size: 25px;padding-left: 15px;" @click="class_sort" v-if="search_type"></i>
				</i>
			</navitop>
		</div>
		<view :style="'padding-top:' + nv_height" >
		
			<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption" :style="'padding-top:' + nv_height_lsit + '%'">
				<fontListan :rundata="dataSorce" :somvo='somvo' :rulCode="curl_option" v-if="curl_type"></fontListan>
			</mescroll-body>
		</view>
		
		<!-- 气泡弹窗 -->
		 <chunLei-popups v-model="value" :popData="datas" @tapPopup="bubble" :x="345" :y="95" placement="top-end">
		 </chunLei-popups>
	</view>
</template>

<script>
	import navitop from '@/components/common/navi-top'
	import {list,voucherDynamicPage,pageVInventoryCheckMain,statisticStorageOnHandVo,statisticInOutRecordDetailVo,SummaryVo,ParentVo} from '@/common/api/job/sale.js'
	import {Plist,voucherPage} from '@/common/api/job/bill.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import fontListan from '@/pages/common/common/list/fontlist_analysis.vue'
	import chunLeiPopups from "@/components/chunLei-popups/chunLei-popups";
	export default {
		components: {
			navitop,
			chunLeiPopups,
			fontListan
		},
	mixins: [MescrollMixin],
	data(){
		return {
			titles: '',
			nv_height: '',	//获取导航高度
			nv_height_lsit: '',	//获取导航高度
			value:false,
			datas: [
				{title:'添加',code:'billadd',icon:'icon-tubiao_tianjia'}
			],
			// 下拉刷新的配置
			downOption: {
				auto: false,
				beforeEndDelay: 300
			},
			// 上拉加载的配置
			upOption: {
				auto: false,
				page: {
					size: 10 // 每页数据的数量,默认10
				},
				noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
				empty: {
					use: true,
					tip: '暂无相关数据'
				},
				textNoMore: '没有更多数据了...',
				toTop: {
					offset: 1000 // 滚动多少才显示to-top 
				}
			},
			title_list: [],
			rundataSorce: [],
			sort_code: '',
			out_code: '',
			pages: 1,	// 分页
			sort_key: '',
			c_code: '',	// 是否入库
			
			deliver_type: 0,	//  特殊处理发货单
		
			deliver_title_list: [],	// 区分发货单特殊处理
			
			Curl_Data: '',	// 获取url参数
			
			curl_option: '',
			
			curl_type: false,
			
			curl_type_one: true,
			
			dataSorce: [],
			
			somvo: '',
			
			search_data_list: [],	//搜索方案列表
			
			search_type: false,
			
			second_class: '',
			
			second_class_id:'',
			
			second_class_list:'second_serch_top',

		}
	},
	onLoad(val) {
		this.curl_option = val;
		this.Curl_Data = val;
		this.titles = val.title;
		this.sort_code = val.code;
		this.out_code = val.sort;
		this.sort_key = val.key;
		this.c_code = val.c_code;
		if(val.code == '0'){
			this.search_type = true;
		}
	},
	mounted() {
		this.nv_height = uni.getSystemInfoSync().statusBarHeight + 55 + 'px';
		if(this.curl_option.tak == "1"){
			this.curl_type_one = false;
			this.curl_type = true;
			if(this.curl_option.msg == 'Inventory'){
				this.Inventory_list(this.pages);
			}
			
		}else {
			this.getList(this.pages);
		}
		
	},
	methods: {
		
		// 返回
		outlot(){
			uni.switchTab({
				url: '/pages/index/index'
			})
		},
		
		// 气泡弹窗
		class_sort(){
			this.value = !this.value;
		},
		
		// 弹窗操作
		bubble(val){
			uni.navigateTo({
				url: '/pages/common/index/purchase/inventory/Inventory-add?tak=' + this.Curl_Data.tak + '&code=' + this.Curl_Data.code + '&msg=' + this.Curl_Data.msg + '&title=' + this.Curl_Data.title
			})
		},
		
		// 获取盘存盈亏列表
		Inventory_list(pages){
			let tL_type = false; 
			if(this.curl_option.code == '1'){
				tL_type = true;
				this.somvo = 1;
			}
			pageVInventoryCheckMain({current: pages,size: 10,isLossOrGain: tL_type}).then(item => {
				if(item.code == 200){
					if(pages == 1){
						this.dataSorce = item.data.records;
					}else{
						item.data.records.filter(val => {
							this.dataSorce.push(val)
						})
					}
				}
			})
		},
		
		
		/*下拉刷新的回调*/
		downCallback(val) {
			// 下拉刷新和上拉加载调同样的接口,直接mescroll.resetUpScroll()即可
			
			if(this.curl_option.msg == 'Inventory' || this.curl_option.msg == 'analysis'){
				if(this.curl_option.msg == 'Inventory'){
					this.Inventory_list(this.pages);
				}else if(this.curl_option.msg == 'analysis') {
					this.analysis_list(this.pages);
				}
			}else{
				this.getList(this.pages);
			}
			
			setTimeout(() => {
				this.mescroll.endSuccess();
			}, 500)
		},
		
		// 上拉加载
		upCallback(page) {
			this.pages++;
			let sun = this.pages;
			if(this.curl_option.msg == 'Inventory' || this.curl_option.msg == 'analysis'){
				if(this.curl_option.msg == 'Inventory'){
					this.Inventory_list(sun);
				}else if(this.curl_option.msg == 'analysis') {
					this.analysis_list(sun);
				}
			}else{
				this.getList(sun);
			}
			// let obj = {
			// 	current: page.num, // 页码, 默认1
			// 	size: page.size, // 页长, 默认10条
			// };
			setTimeout(()=>{
				this.mescroll.endErr();
			},500)
		},
	}
}
</script>

<style scoped lang="scss">
// 头部切换
.second_serch {
	height: 90rpx;
	width: 100%;
	line-height: 90rpx;
	background-color: #fff;
	margin-bottom: 10px;
	padding: 0 10px 0 10px;
	display: flex;
	// justify-content: space-between;
	white-space: nowrap;
	overflow-x: scroll;
	overflow-y: hidden;
	div {
		padding:  0 40rpx 0 40rpx;
	}
}

//头部切换样式背景
.second_serch_top{
	background-color: rgb(34, 131, 228);
	color:#fff;
}
</style>
